<?php

require 'Slim/Slim.php';

$app = new Slim();

include ("Common.php");
include ("func_api_alertas.php");
include ("func_api_categorias.php");
include ("func_api_noticias.php");
include ("func_api_push.php");
include ("func_api_incidencias.php");
include ("func_api_eventos.php");

//Alertas
$app->get('/alertas', 'getAlertas');
$app->get('/alertas/categorias', 'getAlertasCategorias');
$app->get('/alertas/:id', 'getAlerta');

//$app->post('/alertas', 'addAlerta');
//$app->put('/alertas/:id', 'updateAlerta');
//$app->delete('/alertas/:id', 'deleteAlertas');

//Categorias
$app->get('/categorias', 'getCategorias');
$app->get('/categorias/filtro', 'getCategoriasFiltro');
$app->get('/categorias/:id', 'getCategoria');

//Noticias
$app->get('/noticias', 'getNoticias');
$app->get('/noticias/categorias', 'getNoticiasCategorias');
$app->get('/noticias/:id', 'getNoticia');

//Push Api
$app->post('/push/device', 'addDevice');
$app->get('/push/send', 'sendPush');

//Incidencia
$app->get('/incidencia', 'addIncidencia');
$app->get('/incidencia/image', 'addImageIncidencia');

//Eventos
$app->get('/eventos', 'getEventos');
$app->get('/eventos/:id', 'getEvento');

$app->run();

function getConnection() {

	//ACCESO LOCAL
	//$dbhost="localhost";
	//$dbuser="root";
	//$dbpass="";
	//$dbname="notificaciones_sx";
	
	//ACCESO FreeHostia
	//$dbhost="mysql2.freehostia.com";
	$dbhost="198.23.57.16";
	$dbuser="davfer25_sx";
	$dbpass="s0mxarxa";
	$dbname="davfer25_sx";

	//ACCESO 1and1
	//$dbhost="db526006310.db.1and1.com";
	//$dbuser="dbo526006310";
	//$dbpass="s0mxarxa";
	//$dbname="dbo526006310";
	
	
	//PUSH Notificaciones
	// Google Cloud Messaging API Key
	// Place your Google API Key
	define("GOOGLE_API_KEY", "AIzaSyCo8stgoProF0nYEstl8m_Hrriv2Uncwt8");

	//Used by Client
	//SENDER_ID= "916742317479"


	$dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));	
	$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
	return $dbh;
}

?>